package com.example.social.utils

import android.annotation.SuppressLint
import android.content.Context
import android.content.Context.MODE_PRIVATE


object SharedPref {
    fun storeData( nickname: String,email:String, bio: String, userName: String,imageUrl:String,uid:String,context: Context) {
        val sharedPreferences = context.getSharedPreferences("users", MODE_PRIVATE)
        val editor = sharedPreferences.edit()
        editor.putString("nickname", nickname)
        editor.putString("email", email)
        editor.putString("bio", bio)
        editor.putString("userName", userName)
        editor.putString("imageUrl", imageUrl)
        editor.putString("uid",uid)
        editor.apply()
    }

    fun cleanData(context: Context){
        val sharedPreferences = context.getSharedPreferences("users", MODE_PRIVATE)
        val edit = sharedPreferences.edit()
        edit.clear()
        edit.apply()
    }

    fun getUid(context:Context):String{
        val sharedPreferences = context.getSharedPreferences("users", MODE_PRIVATE)
        return sharedPreferences.getString("uid","")!!
    }
    fun getUserName(context:Context):String{
        val sharedPreferences = context.getSharedPreferences("users", MODE_PRIVATE)
        return sharedPreferences.getString("userName","")!!
    }
    fun getEmail(context:Context):String{
        val sharedPreferences = context.getSharedPreferences("users", MODE_PRIVATE)
        return sharedPreferences.getString("email","")!!
    }
    fun getBio(context:Context):String{
        val sharedPreferences = context.getSharedPreferences("users", MODE_PRIVATE)
        return sharedPreferences.getString("bio","")!!
    }
    fun getName(context:Context):String{
        val sharedPreferences = context.getSharedPreferences("users", MODE_PRIVATE)
        return sharedPreferences.getString("nickname","")!!
    }
    fun getImageUrl(context:Context):String{
        val sharedPreferences = context.getSharedPreferences("users", MODE_PRIVATE)
        return sharedPreferences.getString("imageUrl","")!!
    }
}
